package com.example.myapplication

import android.util.Log

/**
 * 抽象与多态
 */
fun main(args: Array<String>) {
    val persion1 = Man("LX")
    val persion2 = Woman("lml")
    val list = listOf<Human>(persion1, persion2)
    for (h in list) {
        h.eat()
    }
}

abstract class Human(var humanName: String) {
    abstract fun eat()
}

class Man(humanName: String) : Human(humanName) {
    override fun eat() {
        Log.e("main", "${humanName}正在吃")
    }

}

class Woman(humanName: String) : Human(humanName) {
    override fun eat() {
        Log.e("main", "${humanName}正在吃")
    }

}